package com.kinghunt.misp.common.enums.devicex;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 设备状态类型枚举
 */
public enum DeviceRepairTypeEnum {
    /**
     * 维修类型（1:损坏、2:失灵、3:改装）
     */
    DEVICE_REPAIR_TYPE_1(1, "损坏"),
    DEVICE_REPAIR_TYPE_2(2, "失灵"),
    DEVICE_REPAIR_TYPE_3(3, "改装");

    @Getter
    private Integer value;
    @Getter
    private String desc;

    DeviceRepairTypeEnum(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    private final static Map<Integer, DeviceRepairTypeEnum> map = new HashMap<>(8);
    static {
        for (DeviceRepairTypeEnum e : DeviceRepairTypeEnum.values()) {
            map.put(e.getValue(), e);
        }
    }

    public static DeviceRepairTypeEnum getByType(Integer value) {
        if (Objects.isNull(value)) {
            return null;
        }
        return map.get(value);
    }
}
